﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BookShelf.Model
{
    public class RatedBook : Book
    {

        private float roundAmount = 0.5F;
        private const float minRating = 0F;
        private const float maxRating = 5F;

        public float Rating { get; protected set; }

        public RatedBook(int id, string isbn, string title, DateTime publicationDate, int pages, float rating)
            : base(id, isbn, title, publicationDate, pages)
        {

            if (rating % roundAmount != 0)
                throw new ArgumentOutOfRangeException("rating must be in increments of " + roundAmount.ToString());

            if (rating < minRating || rating > maxRating)
                throw new ArgumentOutOfRangeException(string.Format("rating must be between {0} and {1}", minRating.ToString(), maxRating.ToString()));
            
            this.Rating = rating;
        }

    }
}
